package algorithm.poj.p2000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;

/**
 * 分析：
 * 实现：
 * 经验：
 * 教训：
 * 分类：字符串
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P2406 {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P2406.class.getResource("P2406.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		String line = stdin.readLine();
		while (line != null && !".".equals(line)) {
			System.out.println(power(line.trim().toCharArray()));
			line = stdin.readLine();
		}
	}

	private static int power(char[] cs) {
		
		int n = cs.length;
		for (int k = n; k > 0; k --) {
			if (n%k == 0) {
				if (check(cs, k)) {
					return k;
				}
			}
		}
		return -1;
	}
	
	private static boolean check(char[] cs, int k) {

		int s = cs.length/k;
		for (int i = 0; i < s; i ++) {
			for (int j = 1; j < k; j ++) {
				if (cs[i] != cs[i+j*s]) return false;
			}
		}
		return true;
	}
}